package org.ggn.action;

import java.io.File;
import java.io.IOException;

import org.apache.commons.io.FileUtils;
import org.ggn.dao.CourseDao;
import org.ggn.model.Course;
import org.ggn.model.SJFile;
import org.ggn.util.DirFinalValue;

public class SJFileAction {
	private File[] sjFile;
	private String[] sjFileFileName;
	private String[] sjFileContentType;
	
	
	public File[] getSjFile() {
		return sjFile;
	}
	public void setSjFile(File[] sjFile) {
		this.sjFile = sjFile;
	}
	public String[] getSjFileFileName() {
		return sjFileFileName;
	}
	public void setSjFileFileName(String[] sjFileFileName) {
		this.sjFileFileName = sjFileFileName;
	}
	public String[] getSjFileContentType() {
		return sjFileContentType;
	}
	public void setSjFileContentType(String[] sjFileContentType) {
		this.sjFileContentType = sjFileContentType;
	}
	public String fileInput(){
		return "fileInput";
	}
	public String file(){
		try {
			CourseDao cd = new CourseDao();
			Course c = cd.load(8);
			for(int i =0;i<sjFile.length;i++){
				File f = sjFile[i];
				String fn = sjFileFileName[i];
				String filename = DirFinalValue.rootpath+"\\"+c.getGrade().getName()+"\\"+c.getShortname()+c.getpaper_year_an()+"\\"+fn;
				System.out.println(filename);
				FileUtils.copyFile(f, new SJFile(filename));
			}
		} catch (IOException e) {
			e.printStackTrace();
		}
		return "file";
	}
}
